package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.elasticsearch.pojo.XbbAggregatedPage;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.applist.pojo.vo.ListAppVO;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.businesstage.pojo.vo.ChangeClueStatusVO;
import com.xbongbong.pro.clue.pojo.dto.ChangeClueStatusDTO;
import com.xbongbong.pro.common.pojo.dto.CustomerCheckRepeatDTO;
import com.xbongbong.pro.customer.pojo.dto.ClueDeleteBatchDTO;
import com.xbongbong.pro.customer.pojo.dto.CustomerEditAttrUpdateDTO;
import com.xbongbong.pro.customer.pojo.vo.CustomerEditAttrUpdateVO;
import com.xbongbong.pro.formdata.pojo.AfterSavePojo;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainInLinkItemDTO;
import com.xbongbong.pro.listbatch.pojo.dto.AddLabelDTO;
import com.xbongbong.pro.marketManage.pojo.dto.ClueUpdateBatchDTO;
import com.xbongbong.pro.opportunity.pojo.vo.ClueDeleteBatchVO;
import com.xbongbong.pro.opportunity.pojo.vo.ClueUpdateBatchVO;

import java.util.List;

public interface ClueService {
    /**
     * 保存前saas特殊校验
     *
      * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @throws XbbException 业务异常
     */
    AfterSavePojo afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;


    /**
     * 新建时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 格式化导出值
     *
     * @param paasFormDataESList 数据
     * @throws XbbException 异常
     */
    void formatExportValue(List<PaasFormDataEntityExt> paasFormDataESList, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 封装线索查重
     * @param customerCheckRepeatDTO
     * @return
     */
    XbbAggregatedPage<PaasFormDataEntityExt> getDuplicateClue(CustomerCheckRepeatDTO customerCheckRepeatDTO) throws XbbException;

    /**
     * 格式化移动端列表页
     *
     * @param formDataListDTO 用户
     * @param esEntities 业务实体集合
     * @param totalCount 总数
     * @return ListAppVO
     * @throws XbbException
     */
    ListAppVO formatClueAppList(FormDataListDTO formDataListDTO, List<PaasFormDataEntityExt> esEntities, Integer totalCount) throws XbbException;

    /**
     * 批量删除线索
     * @param clueDeleteBatchDTO
     * @return com.xbongbong.pro.customer.pojo.vo.ClueDeleteBatchVO
     * @throws XbbException 业务异常
     */
    ClueDeleteBatchVO deleteBatch(ClueDeleteBatchDTO clueDeleteBatchDTO) throws XbbException;

    /**
     * @Description: 关联新建时格式化解释
     * @Param: [handlerExplainInLinkItemDTO]
     * @return: void
     */
    void formatLinkAddExplain(HandlerExplainInLinkItemDTO handlerExplainInLinkItemDTO) throws XbbException;

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 批量编辑某个字段
     * @param customerEditAttrUpdateDTO
     * @return com.xbongbong.pro.customer.pojo.vo.CustomerEditAttrUpdateVO
     * @throws XbbException 业务异常
     */
    CustomerEditAttrUpdateVO batchEditAttr(CustomerEditAttrUpdateDTO customerEditAttrUpdateDTO) throws XbbException;

    ChangeClueStatusVO invalidClue(ChangeClueStatusDTO changeClueStatusDTO) throws XbbException;

    ChangeClueStatusVO followClue(ChangeClueStatusDTO changeClueStatusDTO) throws XbbException;

    void updateBatchLabelAttr(AddLabelDTO addLabelDTO, List<PaasFormDataEntityExt> addBatchList, Boolean addOrDelete) throws XbbException;

    /**
     * 更新
     * @author 吴峰
     * @date 15:42 2019/2/15
     * @desrcption
     * @param clueUpdateBatchDTO
     * @return void
     * @throws XbbException 业务异常
     */
    ClueUpdateBatchVO clueUpdateBatch(ClueUpdateBatchDTO clueUpdateBatchDTO) throws XbbException;

    void dataConsistencyUpdateMarketActivity(String corpid, Long dataId, String name) throws XbbException;

    void afterSaveForWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    void afterSaveForUpdateWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;
}
